package com.xiaohong.oauth.code;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author : xiaohong
 * @date : 2021/4/30 11:14
 * 授权码模式
 */
@SpringBootApplication
// 开启Spring security注解
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SpringSecurityOauth2CodeApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringSecurityOauth2CodeApplication.class,args);
    }

    /**
     * 在进行自定义登录实例时，容器里必须有PasswordEncoder实例
     * @return
     */
    @Bean
    public PasswordEncoder getPw(){
        return new BCryptPasswordEncoder();
    }
}
